<template>
  <div class="visitor">
    <div class="top">
      <div class="left">
        <span class="free">{{user.isInsure==1?'医保':'自费'}}</span>
        <span class="username">{{ user.name }}</span>
      </div>
      <div class="right">
        <el-button type="primary" size="default" circle :icon="Edit" @click.stop="handler"></el-button>
        <slot></slot>
      </div>
    </div>
    <div class="bottom">
      <p>证件类型：{{user.param.contactsCertificatesTypeString}}</p>
      <p>证件号码：{{user.certificatesNo}}</p>
      <p>患者性别：{{user.sex==1?'男':'女'}}</p>
      <p>出生日期：{{user.birthdate}}</p>
      <p>手机号码：{{user.phone}}</p>
      <p>婚姻状况：{{user.isMarry==1?'已婚':'未婚'}}</p>
      <p>当前住址：{{user.param.cityString}}</p>
      <p>详细地址：{{user.param.fullAddress}}</p>
      <!-- 红色的已选择的盒子 -->
      <transition name="confirm">
        <div class="confirm" v-if="index==currentIndex">已选择</div>
      </transition>
    </div>
  </div>
</template>
      
<script lang="ts" setup>
import { Edit } from "@element-plus/icons-vue";
import { useRoute, useRouter } from "vue-router";
let route = useRoute();
let router = useRouter();
// 接收父组件传递过来的就诊人信息
// @ts-ignore
let props = defineProps(["user", "index", "currentIndex"]);
// @ts-ignore
let $emit = defineEmits(["changeScene"]);
// 编辑
const handler = () => {
  // 要么是就诊人管理模块点击修改按钮
  // 要么预约挂号点击修改按钮
  if (route.path == "/user/patient") {
    $emit("changeScene", props.user);
  } else {
    // 路由跳转携带参数
    router.push({
      path: "/user/patient",
      query: { type: "edit", id: props.user.id }
    });
  }
};
</script>
      
<style lang="scss" scoped>
.visitor {
  box-shadow: 0px 0px 12px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  .top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 60px;
    padding: 0 20px;
    background-color: #fafafa;
    .left {
      .free {
        background-color: #fff;
        padding: 0 5px;
        font-size: 14px;
        margin-right: 5px;
        border-radius: 10px;
      }
      .username {
        color: #7f7f7f;
      }
    }
  }
  .bottom {
    position: relative;
    padding: 20px;
    p {
      line-height: 40px;
      font-size: 14px;
      color: #333;
    }
    .confirm {
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%) rotate(45deg);
      width: 200px;
      height: 200px;
      line-height: 200px;
      text-align: center;
      color: red;
      border-radius: 50%;
      border: 1px dashed red;
      opacity: 0.3;
    }
    // .confirm-enter-from {
    //   transform: scale(1);
    // }
    // .confirm-enter-active {
    //   transition: all 0.3s;
    // }
    // .confirm-enter-to {
    //   transform: scale(1.2);
    // }
  }
}
</style>
  
  